package com.ftdigital.primemovers_operators.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ftdigital.primemovers_operators.MainActivity;
import com.ftdigital.primemovers_operators.R;

/**
 * Created by Curry on 2015-12-21.
 */
public class TextListAdpter extends BaseAdapter {

    private String[] data;
    private Context context;

    public TextListAdpter(Context context, String[] data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.length;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.text_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.dataItem.setText(data[i]);
        return convertView;
    }

    public static class ViewHolder {
        public TextView dataItem;

        public ViewHolder(View v) {
            dataItem = (TextView) v.findViewById(R.id.item_data);
        }

    }
}
